#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
int main()
{
    pid_t id = fork();
    if (id == 0)
    {
        while (1)
        {
            printf("child, pid: %d, ppid: %d\n", getpid(), getppid());
            sleep(1);
        }
    }
    else
    {
        int cnt = 15;
        while (cnt--)
        {
            printf("parent, pid: %d, ppid: %d\n", getpid(), getppid());
            sleep(1);
        }
        int status = 0;
        pid_t ret = waitpid(id, &status, 0);
        if (ret == id)
        {
            printf("ret: %d, exit_singal: %d, exit_code: %d\n", ret, status&0x7F, (status>>8)&0xFF);
        }
        sleep(5);
    }
    return 0;
}
